package apps.project.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
import org.springframework.stereotype.Service;

import apps.project.dao.ProjectManageDao;
import apps.project.domain.ProjectManageBean;
import core.tool.common.StringHelper;

@Service("projectManageService")
public class ProjectManageService {
	
    @Autowired
	private ProjectManageDao projectManageDao;
	
	public Page<ProjectManageBean> findByTypePager(String type,Pageable pageable) {
		Direction direction=Direction.DESC;
		Order order=new Order(direction,"createTime");
		new Sort(order);
		
		
		return projectManageDao.findByType(type, pageable);
	}
    
	
	public Object save(ProjectManageBean projectManageBean) {
		if(StringHelper.isEmpty(projectManageBean.getId())) {
			projectManageBean.setId(StringHelper.getUUID());
			projectManageBean.setCreateTime(new Date());
		}
		return projectManageDao.save(projectManageBean);
	}
	
	public Object delete(ProjectManageBean projectManageBean) {
		projectManageDao.delete(projectManageBean);
		return 1;
	}
	
	public ProjectManageDao getProjectManageDao() {
		return projectManageDao;
	}

	public void setProjectManageDao(ProjectManageDao projectManageDao) {
		this.projectManageDao = projectManageDao;
	}
	

	
	
	
	
}
